package top.laoshuzi.designpatterns.base.structure.composite;

import org.junit.Test;

public class Client {

    @Test
    public void operation() {
        try {
            Component root = new Composite("root");

            Component node1 = new Unit("node1");
            Component node2 = new Composite("node2");
            root.add(node1);
            root.add(node2);

            Component node3 = new Unit("node3");
            Component node4 = new Unit("node4");
            node2.add(node3);
            node2.add(node4);

            System.out.println(root);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
